package com.syher.security.web.controller;

import com.syher.security.web.model.User;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shenyuhang on 2018/3/20.
 */
//@Controller
public class FrameController {

    @RequestMapping("/index")
    @ResponseBody
    public String hello(){
        User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return String.format("hello, %s", user.getNickname());
    }

    @RequestMapping("/more")
    @ResponseBody
    public String register() {
        return "停止啊，住手！停下你的暴行，你要做什么。啊~~变态。。.";
    }

    @RequestMapping("/admin")
    @ResponseBody
    public String admin() {
        return "来吧，骚年~.";
    }
}
